package com.example.splash;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity3 extends AppCompatActivity {


    private TextView textView;
    private Spinner spinner2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);

        textView = findViewById(R.id.textView);
        spinner2 = findViewById(R.id.spinner2);

        spinner2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            //         那个被选择                               选择用户被选择，返回view形式
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                TextView spinner2_view1 = (TextView) view;
                String spinner_sting = spinner2_view1.getText().toString();
                textView.setText(spinner_sting);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
                Toast.makeText(MainActivity3.this, "用户选择", Toast.LENGTH_SHORT).show();
            }
        });
        Button button = findViewById(R.id.button4);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =new Intent(MainActivity3.this,MainActivity5.class);
                startActivity(intent);
            }
        });
    }
}